package com.ymatou.iapi.messageroute.parameter;

import java.util.HashMap;
import java.util.Map;

public enum BizTypeEnum {

	/**
	 * 取消订单
	 */
	CANCEL_ORDER(1, "CancelOrder"),

	/**
	 * 提前x小时通知用户将要自动确认收货
	 */
	RECEIVE_NOTICE(5, "ReceiveNotice"),

	/**
	 * 接单
	 */
	ACCEPT_ORDER(6, "AcceptOrder"),

	/**
	 * 发货
	 */
	DISPATCHED(10, "Dispatched"),

	/**
	 * 延长收货
	 */
	DELAY_RECEIVE(13, "DelayReceive"),

	/**
	 * 更新收件人地址
	 */
	CHANGE_ORDER_ADDRESS(15, "ChangeAddress"),

	/**
	 * 快速退款
	 */
	FAST_REFUND(20, "FastRefund"),

	/**
	 * 订单未支付即将关闭通知
	 */
	NO_PAY_NOTIFY(27, "NoPayNotify"),

	/**
	 * 发放优惠券
	 */
	SEND_COUPON(30, "SendCoupon"),

	/**
	 * 买手注册-未提交审核材料
	 */
	UnSubmitMaterial(100, "UnSubmitMaterial"),

	/**
	 * 买手注册-审核失败
	 */
	AuditFailure(101, "AuditFailure"),

	/**
	 * 买手注册-审核成功
	 */
	AuditPassed(102, "AuditPassed"),

	/**
	 * 审核通过仍未发布商品的第3天（72小时）
	 */
	UnpublishedProduct(103, "UnpublishedProduct");

	private static final Map<Integer, BizTypeEnum> maps = new HashMap<Integer, BizTypeEnum>();

	static {
		for (BizTypeEnum bizTypeEnum : BizTypeEnum.values()) {
			maps.put(bizTypeEnum.getCode(), bizTypeEnum);
		}
	}

	int code;

	String messageCode;

	BizTypeEnum(int code, String messageCode) {
		this.code = code;
		this.messageCode = messageCode;
	}

	public static BizTypeEnum findByCode(Integer code) {
		BizTypeEnum bizTypeEnum = maps.get(code);
		if (bizTypeEnum == null) {
			throw new IllegalArgumentException("BizTypeEnum not found,code:"
					+ code);
		}
		return bizTypeEnum;
	}

	public String getMessageCode() {
		return this.messageCode;
	}

	public int getCode() {
		return this.code;
	}
}
